class NumArray:
    def __init__(self, nums):
        self.array=nums
        self.dpSum=[0 for _ in range(len(nums))]
        self.dpSum[0]=self.array[0]
        for index in range(1,len(nums)):
            self.dpSum[index]=nums[index]+self.dpSum[index-1]
        print(self.dpSum)
    def sumRange(self, left: int, right: int) -> int:
        # sum=0
        # for index in range(left,right+1):
        #     sum+=self.array[index]
        # return sum
        if left==0:
            return self.dpSum[right]
        else:
            return self.dpSum[right]-self.dpSum[left-1]

nums=[-2,0,3,-5,2,-1]
obj=NumArray(nums)
print(obj.sumRange(0,5))
